package com.lsq.asyndemo.service;

import com.lsq.asyndemo.pojo.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class PriceCalculateService {

    public Order intensiveCalculation(Order order) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        order.setPrice("100");
        order.setMsg("计算完成");
        log.info("赋值: {},{},{}", order.getOrderId(), order.getPrice(), order.getMsg());
        return order;
    }

    public void updateDB(Order order) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.info("更新数据库: {},{},{}", order.getOrderId(), order.getPrice(), order.getMsg());
    }
}
